/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86184
 * Date: 2023-02-18
 * Time: 12:59
 */

class Money1 implements Cloneable{
    public int m=99;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Money2 implements Cloneable{
    public int n=50;
}

class Person1 implements Cloneable{
    public int id;
    public Money1 money=new Money1();
    public Money2 money1=new Money2();
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person1 tmp=(Person1) super.clone();
        tmp.money=(Money1) this.money.clone();
        return tmp;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                '}';
    }
}

public class InterfaceUsageInstance {
    public static void main(String[] args) throws CloneNotSupportedException{
        Person1 person1=new Person1();
        Person1 person2=(Person1) person1.clone();

        System.out.println("浅拷贝");
        person2.money1.n=1900;
        System.out.println(person1.money1.n);
        System.out.println(person2.money1.n);

        System.out.println("深拷贝");
        person2.money.m=1500;
        System.out.println(person1.money.m);
        System.out.println(person2.money.m);
    }
}
